import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderSettingVO, OrderSettingForm, OrderSettingQuery } from '@/api/goods/orderSetting/types';

/**
 * 查询订单列表
 * @param query
 * @returns {*}
 */

export const listOrderSetting = (query?: OrderSettingQuery): AxiosPromise<OrderSettingVO[]> => {
  return request({
    url: '/order/orderSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单详细
 * @param id
 */
export const getOrderSetting = (id: string | number): AxiosPromise<OrderSettingVO> => {
  return request({
    url: '/order/orderSetting/' + id,
    method: 'get'
  });
};

/**
 * 查询订单详细
 */
export const getOrderStateList = (): AxiosPromise<OrderSettingVO> => {
  return request({
    url: '/order/orderSetting/orderStateList',
    method: 'get'
  });
};
/**
 * 查询订单详细
 */
export const getPrintList = (): AxiosPromise<OrderSettingVO> => {
  return request({
    url: '/order/orderSetting/printList',
    method: 'get'
  });
};
/**
 * 查询订单详细
 */
export const getOrderSettingAllList = (): AxiosPromise<OrderSettingVO> => {
  return request({
    url: '/order/orderSetting/allList',
    method: 'get'
  });
};

/**
 * 新增订单
 * @param data
 */
export const addOrderSetting = (data: OrderSettingForm) => {
  return request({
    url: '/order/orderSetting',
    method: 'post',
    data: data
  });
};
/**
 * 新增订单
 * @param data
 */
export const updatePrintStatus = (ids: String) => {
  return request({
    url: `/order/orderSetting/updatePrintStatus/${ids}`,
    method: 'post'
  });
};

/**
 * 新增订单
 * @param data
 */
export const customAdddictLabel = (data: any) => {
  return request({
    url: '/system/dict/data/customAdd',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单
 * @param data
 */
export const updateOrderSetting = (data: OrderSettingForm) => {
  return request({
    url: '/order/orderSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单
 * @param id
 */
export const delOrderSetting = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/orderSetting/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param orderSettingId 客户端id
 * @param status 状态
 */
export function changeStatus(orderSettingId: string, status: string) {
  const data = {
    orderSettingId,
    status
  };
  return request({
    url: '/order/orderSetting/changeStatus',
    method: 'put',
    data: data
  });
}

export default {
  list:listOrderSetting,
  get:getOrderSetting,
  add:addOrderSetting,
  update:updateOrderSetting,
  del:delOrderSetting,
  getOrderSettingAllList:getOrderSettingAllList
}